package com.cal.utms.action.maintenance;

import com.cal.utms.dao.maintenance.IssuerDaoImpl;
import com.cal.utms.dto.maintenance.IssuerDto;
import com.cal.utms.model.maintenance.IssuerModel;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class IssuerAction extends ActionSupport implements ModelDriven<IssuerDto> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	IssuerDaoImpl daoImpl = new IssuerDaoImpl();
	private IssuerDto issuerDto = new IssuerDto();
	private boolean success;
	private String bankAccounts;
	private String contactPersons;
	private int issuerId;
	IssuerModel issuerModel = new IssuerModel();

	public String saveIssuer() {
		issuerModel.saveIssuer(issuerDto, bankAccounts, contactPersons);
		return Action.SUCCESS;
	}

	public String issuerUpdate() {
		issuerModel.update(issuerId, issuerDto, bankAccounts, contactPersons);
		return Action.SUCCESS;
	}

	public String getAllIssuer() {
		success = true;
		issuerDto.setIssuerDtos(issuerModel.createIssuerDtoList(daoImpl.getAllIssuers()));
		return Action.SUCCESS;
	}

	public String getPrimaryDealers() {
		issuerDto.setIssuers(daoImpl.getAllPrimaryDealers());
		return Action.SUCCESS;
	}

	public String getUnMappedIssuer() {
		issuerModel.getUnmapingIssuer(issuerDto);
		return Action.SUCCESS;
	}

	@Override
	public IssuerDto getModel() {
		return issuerDto;
	}

	public IssuerDto getIssuerDto() {
		return issuerDto;
	}

	public void setIssuerDto(IssuerDto issuerDto) {
		this.issuerDto = issuerDto;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getBankAccounts() {
		return bankAccounts;
	}

	public void setBankAccounts(String bankAccounts) {
		this.bankAccounts = bankAccounts;
	}

	public String getContactPersons() {
		return contactPersons;
	}

	public void setContactPersons(String contactPersons) {
		this.contactPersons = contactPersons;
	}

	public int getIssuerId() {
		return issuerId;
	}

	public void setIssuerId(int issuerId) {
		this.issuerId = issuerId;
	}

}
